const host = 'http://localhost:3010'

const zhuanhua = (json={}) => {
  // a = 值 & 拼接
  const arr = []
  for(let key in json) {
    arr.push( key + '=' + json[key])
  }
  return arr.join('&')
}

export const http = ({url,params={},data={},method}) => {
  if(!url) return
  return new Promise( (resolve, reject) => {
    wx.request({
      url: host + url + '?' + zhuanhua(params),
      method:method,
      data: data,
      success(data){
        resolve(data)
      },
      fail(errMsg){
        reject(errMsg)
      }
    })
  } )
}
